<script type="text/javascript">
	
function IsPopOrder(pushV, popV)
{
    let arr = [], pV = 0;
    for(let i = 0; i < pushV.length; i++) {
        arr.push(pushV[i])
        // debugger
        while(arr[arr.length-1] == popV[pV] && pV != popV.length ) {
            arr.pop()
            pV++
        }
    }
    
    return arr.length == 0 ? true : false;
}

const res = IsPopOrder([1,2,3,4,5], [4,5,3,2,1])
console.log(res)

</script>